[Get-ExecutionPolicy], ManagementException when calling PS from SSIS and SQL Server Agent

The long story short: I'm trying to schedule a SSIS package that runs a powershell script/command via a proxy account. The problem seems to be that proxy account didn't have the required permissions to run a .ps1 script, so I've changed the execution policy to "Unrestricted" of everything that could be changed:

                                  Scope                         ExecutionPolicy
                                  -----                         ---------------
                          MachinePolicy                            Unrestricted
                             UserPolicy                            Unrestricted
                                Process                               Undefined
                            CurrentUser                            Unrestricted
                           LocalMachine                            Unrestricted

So far, so good! But when I try to execute the SSIS package with a PS command like this:

powershell.exe -file D:\script.ps1 -FileName testme

I got the error:

AuthorizationManager check failed.
    + CategoryInfo          : SecurityError: (:) [], ParentContainsErrorRecord 
   Exception
    + FullyQualifiedErrorId : UnauthorizedAccess

And when I try the more simple command:

powershell.exe -Command &{Get-ExecutionPolicy}
I get this:

Get-ExecutionPolicy : Access denied At line:1 char:3
+ &{Get-ExecutionPolicy}
+   ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-ExecutionPolicy], Managem 
   entException
    + FullyQualifiedErrorId : System.Management.ManagementException,Microsoft. 
   PowerShell.Commands.GetExecutionPolicyCommand
It's worth mentioning that I can call the regular cmdlets: dir; get-content, whoami, so powershell.exe is working fine! Anyone with an idea what's going on here?








  • Edited by Vesko Jl 18 hours 26 minutes ago
February 9th, 2015 11:25am

Account permissions have nothing to do with Execution Policy.   If an account  does not have permissions then it need to be given permission.
Free Windows Admin Tool Kit Click here and download it now
February 9th, 2015 12:11pm

The account is a regular user, not an admin. I can connect with it and execute the same powershell script without a problem.
February 9th, 2015 12:34pm

The account is a regular user, not an admin. I can connect with it and execute the same powershell script without a problem.

The message is clear "Access Denied" - the account does not have permission.

You need to find what, in your script, is causing access denied.

Free Windows Admin Tool Kit Click here and download it now
February 9th, 2015 12:43pm

SSIS processes cannot elevate a user above what is allowed by the SSIS agent account.  Trying to impersonate will not get you around this.

An Access violation is just that and has no relation to an execution policy.

Try to get your script down two or three lines that cause the issue and I will try to show you how to fix it.

February 9th, 2015 2:20pm

As I said. I tried to execute directly a powershell command, avoiding the script security complications. And the following doesn't work:

-Command &{Get-ExecutionPolicy}

, but strangely enough, following works!
-Command &{whoami}

Free Windows Admin Tool Kit Click here and download it now
February 10th, 2015 1:53am

SSIS processes cannot elevate a user above what is allowed by the SSIS agent account.  Trying to impersonate will not get you around this.

An Access violation is just that and has no relation to an execution policy.

Try to get your script down two or three lines that cause the issue and I will try to show you how to fix it.

February 10th, 2015 2:19am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics